package nsn.message.aggragtor.feeds;

import java.io.IOException;
import java.net.URL;

//import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;

import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.fetcher.FeedFetcher;
import com.sun.syndication.fetcher.FetcherException;
import com.sun.syndication.fetcher.impl.HttpClientFeedFetcher;
import com.sun.syndication.io.FeedException;

/**
 * 
 * 
 * @author Lukasz Nowak
 * @since 10-03-2011
 * 
 */

class FF extends HttpClientFeedFetcher {

	public static final int PROXY_PORT = 8080;
	public static final String PROXY_HOST = "10.144.1.10";
	final HttpClient client = new HttpClient();

	FF() {
		// HostConfiguration config = client.getHostConfiguration();
		// config.setProxy(PROXY_HOST, PROXY_PORT);
	}

	@Override
	public SyndFeed retrieveFeed(URL feedUrl) throws IllegalArgumentException,
			IOException, FeedException, FetcherException {

		return retrieveFeed(feedUrl, client);

	}

}

/**
 * 
 * @author Lukasz Nowak
 * @since 11-03-2011
 * 
 */
public class FeedFetcherService {

	static private FeedFetcher feedFetcher;

	/**
	 * 
	 * 
	 * @return FeedFetcher
	 */
	static public FeedFetcher getFeedFetcher() {
		if (feedFetcher == null) {
			feedFetcher = new FF();
		}
		return feedFetcher;
	}
}
